-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixup getting project path on Windows #1003
Conversation
@md11235 I think it's dangerous if we direct access |
Thank you for you reply. You're correct about this. Previously I only tested the git command provided MSYS2 (https://www.msys2.org/). And I've instead tested the git command provided by "Git for Windows" (https://gitforwindows.org/) just now and it behaved differently. Suppose f:/foo is a local git repository. In MSYS2,
Yet in "Git For Windows",
So it's just the git command from MSYS2 when using the subcommand |
Both these git commands were executed on Windows 10(Version 10.0.19045.4651). |
@@ -362,7 +362,13 @@ def get_project_path(filepath): | |||
import os | |||
dir_path = os.path.dirname(filepath) | |||
if get_command_result("git rev-parse --is-inside-work-tree", dir_path) == "true": | |||
return get_command_result("git rev-parse --show-toplevel", dir_path) | |||
path_from_git = get_command_result("git rev-parse --show-toplevel", dir_path) | |||
if get_os_name() == "windows": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should change to:
if get_os_name() == "windows" and path_from_git.startswith("/"):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or only run convert code when env is MSYS2
thanks for patch |
Sometimes ‘git rev-parse —show-toplevel’ is used in core/utils.py to get project path for an existing source file. That git subcommand would convert a Windows style path like “f:/foo/bar.py” to “/f/foo” and cause unexpected behavior on Windows OS’s.
I’ve made a possible fix to that git behavior. Thank you for reviewing this patch.